import { Observable, Subscriber } from 'rxjs'
import * as express from 'express'
export function createExpress(
  port: number = 3000,
  hostname: string = '0.0.0.0'
): Observable<{ req: express.Request; res: express.Response }> {
  return Observable.create((obser: Subscriber<any>) => {
    const app = express()
    const handler: any = (req: express.Request, res: express.Response) => {
      obser.next({
        req,
        res
      })
    }
    app.get('**', handler)
    app.listen(port, hostname)
  })
}
